Skip to content

fix: defer remote connect lease and metro setup#417

Merged
thymikee merged 1 commit into
mainfrom
fix/deferred-remote-connect-profile
Apr 16, 2026
Merged

fix: defer remote connect lease and metro setup#417
thymikee merged 1 commit into
mainfrom
fix/deferred-remote-connect-profile

Conversation

@thymikee

Copy link
Copy Markdown
Member

Summary

  • support minimal remote connect profiles by auto-generating local session names and deferring lease allocation plus Metro preparation until a later command needs them
  • keep explicit session, platform, leaseBackend, and Metro overrides working while persisting remote connection state that can start without a resolved lease
  • extract deferred remote materialization into src/cli/commands/connection-runtime.ts so the connection command entrypoint stays focused
  • update docs and tests for the new remote flow
  • Touched files: 8. Scope stayed within the remote connection/CLI command family plus tests and docs.
  • Known gaps: none.

Validation

  • pnpm format
  • pnpm check:unit

@github-actions

github-actions Bot commented Apr 16, 2026

Copy link
Copy Markdown
PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://callstackincubator.github.io/agent-device/pr-preview/pr-417/

Built to branch gh-pages at 2026-04-16 15:44 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d57495ce63

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/cli/commands/connection-runtime.ts Outdated
Comment on lines +47 to +51
if (shouldAllocateLeaseForCommand(command)) {
const leaseBackend = state.leaseBackend ?? requireRequestedLeaseBackend(flags, command);
assertRequestedConnectionScope(state, flags, leaseBackend);
if (!state.leaseId || !state.leaseBackend) {
const lease = await allocateOrReuseLease(client, state, leaseBackend);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Refresh persisted lease before command dispatch

The current guard only calls allocateOrReuseLease when !state.leaseId || !state.leaseBackend, so existing persisted leases are never heartbeated/revalidated before use. This makes the reuse branch in allocateOrReuseLease effectively unreachable and causes stale lease IDs (for example after reconnecting to an older saved state) to be passed straight into normal commands, which can fail with unauthorized/expired lease errors instead of being renewed.

Useful? React with 👍 / 👎.

Comment on lines +235 to +236
function shouldAllocateLeaseForCommand(command: string): boolean {
return !leaseDeferredCommands.has(command);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Skip lease materialization for lease-agnostic close

shouldAllocateLeaseForCommand currently forces lease materialization for any command not in the deferred set, which includes close. After a minimal connect state with no resolved backend/lease, running close can now fail early with the backend requirement error before sessions.close executes, even though session close is intended to work without allocating a new lease (as shown by the disconnect flow).

Useful? React with 👍 / 👎.

@thymikee thymikee force-pushed the fix/deferred-remote-connect-profile branch 4 times, most recently from e96abf2 to 2fd1f3f Compare April 16, 2026 15:35
@thymikee thymikee force-pushed the fix/deferred-remote-connect-profile branch from 2fd1f3f to 6173197 Compare April 16, 2026 15:43
@thymikee thymikee merged commit 1b71dfe into main Apr 16, 2026
15 checks passed
@thymikee thymikee deleted the fix/deferred-remote-connect-profile branch April 16, 2026 15:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant